﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace Lab6_Product
{
    public partial class frmLogin : Form
    {
        DataTable dtUser;
        string username;
        string passw;
        public frmLogin()
        {
            InitializeComponent();
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            DataProccess dp = new DataProccess();
            dtUser = dp.getDataLogin();
            cboUser.DataSource = dtUser;
            cboUser.DisplayMember = "StaffCode";
           
        }

        

        private void txtPassword_Enter(object sender, EventArgs e)
        {
            toolTipPassword.SetToolTip(txtPassword, "Default password is 12");
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            DataRowView selectedRow = (DataRowView)cboUser.SelectedItem;
            string pass = txtPassword.Text;
            if (true)
            {
                frmStoreManagement f = new frmStoreManagement();
                this.Hide();
                f.Show();
            }
            //else
            //{
            //    MessageBox.Show("Login Fail! Try to remember your passowrd and staff code");
            //    MessageBox.Show("username: " + username + " pass: " + pass);
            //}
        }

        // don't work, dont know why =.=
        //public bool checkLogin(string password)
        //{
        //    bool result;
        //    DataRowView selectedRow = (DataRowView) cboUser.SelectedItem;
        //    if (password==(selectedRow.Row["password"].ToString()))
        //    {
        //        result = true;
        //    }
        //    else result = false;

        //    return result;
        //}

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cboUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataRowView selectedRow = (DataRowView) cboUser.SelectedItem;
            passw = (selectedRow.Row["password"].ToString());
        }
        

        
    }
}
